package com.cq.hd.member.controller;

import com.cq.hd.common.pagination.Page;
import com.cq.hd.common.response.Result;
import com.cq.hd.common.response.ResultGenerator;
import com.cq.hd.member.api.TbInviteBusinessUrlApi;
import com.cq.hd.member.api.dto.EnterBusinessPageDto;
import com.cq.hd.member.api.dto.InviteBusinessUrlPageDto;
import com.cq.hd.member.api.dto.InviteBusinessUrlSaveDto;
import com.cq.hd.member.api.vo.EnterBusinessPageVo;
import com.cq.hd.member.api.vo.InviteBusinessUrlPageVo;
import com.cq.hd.member.service.TbInviteBusinessUrlService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 邀请商家链接表 前端控制器
 * </p>
 *
 * @author mYunYu
 * @since 2023-11-19
 */
@RestController
public class TbInviteBusinessUrlController implements TbInviteBusinessUrlApi {

    @Autowired
    private TbInviteBusinessUrlService inviteBusinessUrlService;

    @ApiOperation(value = "保存邀请商家链接")
    @ApiImplicitParam(name = "inviteBusinessUrlSaveDto", value = "保存参数", required = true, paramType = "body", dataType = "InviteBusinessUrlSaveDto")
    @Override
    public Result<Object> saveInviteBusinessUrl(@RequestBody InviteBusinessUrlSaveDto inviteBusinessUrlSaveDto) {
        return ResultGenerator.success(inviteBusinessUrlService.saveInviteBusinessUrl(inviteBusinessUrlSaveDto));
    }

    @ApiOperation(value = "邀请商家链接列表")
    @ApiImplicitParam(name = "inviteBusinessUrlPageDto", value = "查询参数", required = true, paramType = "query", dataType = "InviteBusinessUrlPageDto")
    @ApiResponse(response = InviteBusinessUrlPageVo.class, code = 200, message = "接口返回对象参数")
    @Override
    public Result<Page<InviteBusinessUrlPageVo>> pageInviteBusinessUrl(InviteBusinessUrlPageDto inviteBusinessUrlPageDto) {
        return ResultGenerator.success(inviteBusinessUrlService.pageInviteBusinessUrl(inviteBusinessUrlPageDto));
    }

    @ApiOperation(value = "删除邀请商家链接")
    @ApiImplicitParam(name = "id", value = "id", required = true, paramType = "query", dataType = "Long")
    @Override
    public Result<Object> deleteInviteBusinessUrl(Long id) {
        inviteBusinessUrlService.deleteInviteBusinessUrl(id);
        return ResultGenerator.success();
    }

    @ApiOperation(value = "查看入驻商家")
    @ApiImplicitParam(name = "enterBusinessPageDto", value = "查询参数", required = true, paramType = "query", dataType = "EnterBusinessPageDto")
    @Override
    public Result<Page<EnterBusinessPageVo>> pageEnterBusiness(EnterBusinessPageDto enterBusinessPageDto) {
        return ResultGenerator.success(inviteBusinessUrlService.pageEnterBusiness(enterBusinessPageDto));
    }

    @ApiOperation(value = "根据id获取商家邀请码数据")
    @Override
    public Result<InviteBusinessUrlPageVo> getById(Long id) {
        return ResultGenerator.success(inviteBusinessUrlService.getInviteBusinessUrlById(id));
    }
}
